﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolERP_Entities;
using CoolERP_BLL;

namespace CoolERP_Web.User
{
    public partial class YSKSK : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.AspNetPager1.PageSize = GridView1.PageSize;
                BindData();
            }
        }
        public void BindData()
        {
            Dictionary<string, string> dc = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(tbBH.Text.Trim()))
                dc.Add("BH", tbBH.Text.Trim());
            if (!string.IsNullOrEmpty(tbKHJC.Text.Trim()))
                dc.Add("KHJC", tbKHJC.Text.Trim());
            if (!string.IsNullOrEmpty(tbJBRName.Text.Trim()))
                dc.Add("JBRName", tbJBRName.Text.Trim());
            if (!string.IsNullOrEmpty(tbYSKZDBH.Text.Trim()))
                dc.Add("YSKZDBH", tbYSKZDBH.Text.Trim());
            if (!string.IsNullOrEmpty(tbDZRQ.Text.Trim()))
                dc.Add("DZRQ", tbDZRQ.Text.Trim());
            if (!string.IsNullOrEmpty(tbZPHM.Text.Trim()))
                dc.Add("ZPHM", tbZPHM.Text.Trim());
            using (CW_SKDBLL cB = new CW_SKDBLL())
            {
                int RecordCount = 0;
                List<SKDModel> itemLists = cB.QuerySKD(dc, "DZRQ", this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out RecordCount);
                GridView1.DataSource = itemLists;
                GridView1.DataBind();
                this.AspNetPager1.Visible = RecordCount > 0;
                panMsg.Visible = !this.AspNetPager1.Visible;
            }
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
        }
        protected void btnQuery_Click(object sender, ImageClickEventArgs e)
        {
            this.AspNetPager1.CurrentPageIndex = 1;
            BindData();
        }

        protected void btnReset_Click(object sender, ImageClickEventArgs e)
        {
            this.tbBH.Text = "";
            this.tbKHJC.Text = "";
            this.tbJBRName.Text = "";
            this.tbYSKZDBH.Text = "";
            this.tbDZRQ.Text = "";
            this.tbZPHM.Text = "";
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}